import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import i18n from './lang'
// import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import checkPermission from '@/mixin'

import '@/icons' // icon
import '@/permission' // permission control

import * as directives from './directives'
// 统一注册组件
// import components from '@/components'
import '@/components'
import * as filters from '@/filters'
// Vue.use(ElementUI, { zhLocale })
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
/* if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
} */

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)
// 注册添加自定义指令
// Vue.directives('指令名', 相关配置对象)
Object.keys(directives).forEach(item => {
  Vue.directive(item, directives[item])
})

// Vue.use(components) // 调用components中的Install方法，全局注册组件
// 注册所有的全局过滤器
Object.keys(filters).forEach(item => {
  Vue.filter(item, filters[item])
})
// 全局注入 混入对象
Vue.mixin(checkPermission)
Vue.config.productionTip = false
// 设置element为当前的语言
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})
new Vue({
  el: '#app',
  router,
  i18n,
  store,
  render: h => h(App)
})
